<?php
include_once('header.inc.php');
securite();
if(!@checkdate($_POST['mm'],$_POST['jj'],$_POST['aaaa']) || $_POST['aaaa']>date('Y'))
   redirection('ajoutAnniv.php?err=Date de naissance incorrecte');
if($_POST['mail']!='' && !ereg('^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$', $_POST['mail']))
   redirection('ajoutAnniv.php?err=E-mail incorrect');
$data['userlogin'] = $_SESSION['login'];
$data['firstname'] = ucfirst(strtolower($_POST['firstname']));
$data['lastname'] = ucfirst(strtolower($_POST['lastname']));
$data['mail'] = $_POST['mail'];
$data['phone'] = $_POST['phone'];
$data['birthdate'] = $_POST['aaaa'].'-'.$_POST['mm'].'-'.$_POST['jj'];
$db->insert($CONFIG['table_birthdays'],$data);
redirection('ajoutAnniv.php?ok='.$data['firstname'].' '.$data['lastname']);
?>
